/*
Class Name      : AllMessagesController
Created by      : Sreekanth SV Vegi
Created On      : 21/02/2013
Description     : This class helps to Manage All Messages
Version         : 1.0               
*/

 
public with sharing class AllMessagesController {
    
    //Variablest
   public   List<Message__c> AllMessagesList{get; set;}  //Top Message to view on Vf Page
   
    public boolean MessageVisibilityFlag{get;set;}// Result Visible flag
    //public boolean Next5MessagesVisibilityFlag{get;set;}
   // public boolean  activatePostMessage{get; set;}// IsUploadflg visible for CaseManger
    //public Datetime dateforcomparing;
   // IsUploadflg visible for CaseManger
    Message__c Message ;
    
 public AllMessagesController (ConsoleHomeController_AC controller){
    
      Init();
        
        
 }
  public AllMessagesController (){
    Init();
  }
  
  
    void Init()
    {
        
        //activatePostMessage=false;
        //activatePostMessage=true;
        //String ProfileName = [select id, name from profile where id=:UserInfo.getProfileId() LIMIT 1].name;
        //If(ProfileName=='West Case Management - Case Manager'){
        //  activatePostMessage=true;
          
        //}
        this.Message = new   Message__c();
        Message.Description__c=''; 
       MessageVisibilityFlag=false;
       AllMessagesList= [SELECT Name,Description__c,CreatedTime__c FROM Message__c   Order by  CreatedTime__c desc];
       //Next5Messages= [SELECT Name,Description__c,CreatedTime__c FROM Message__c Order by CreatedTime__c  limit 5];
       //MoreMessages= [SELECT Name,Description__c,CreatedTime__c FROM Message__c Order by CreatedTime__c ];
       if(AllMessagesList.size()>0)
         MessageVisibilityFlag=true;
          
        
    }
    
    //Get Message
    public  Message__c getMessage(){
        
        return Message;
        
    }
      
    //===============================================================//
    //========================== Top5Message================================//
    // Helps to Get Top 5 Messages        //
    //===============================================================//
  
  //==============================================================//
    //===Error Function:Helps to diplay error messages on VF page ===//
    //==============================================================//
    public void errMessage(string  ErrMsgStr)
    {
        ApexPages.Message myErrMsg=new ApexPages.Message(ApexPages.Severity.ERROR, ErrMsgStr );
        ApexPages.AddMessage(myErrMsg); 
    }
    
      
    
     //===============================================================//
    //========================== PostMessate================================//
    // Helps to PostMessage         //
    //===============================================================//
     
   
}